//
//  RMMMineAdressTableViewCell.m
//  Romomo
//
//  Created by puman on 2016/12/28.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMMineAdressTableViewCell.h"

@implementation RMMMineAdressTableViewCell
{
    UILabel *_titleLabel;
    UILabel *_contentLabel;
    UILabel *_label;
    UIView *_backView;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _backView = [[UIView alloc] initWithFrame:CGRectMake(15, kRow, kScreenWideth - 30, kHalf * 2 - kRow)];
        _backView.layer.masksToBounds = YES;
        _backView.layer.cornerRadius = 5;
        _backView.layer.borderWidth = 1;
        _backView.layer.borderColor = RGBA(239, 239, 239, 1).CGColor;
        _backView.backgroundColor = kWhiteColor;
        [self.contentView addSubview:_backView];
        
        for (int i = 0; i < 2; i++) {
            if (i == 0) {
                UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(0, 45 * i, _backView.width, 45)];
                subView.backgroundColor = RGBA(245, 246, 247, 1);
                [_backView addSubview:subView];
                
                UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12, 0, 100, subView.height)];
                label.text = @"常用地址";
                label.textColor = COLORFROMCODE(0x2C2C2C, 1);
                label.font = kFont(14);
                [subView addSubview:label];
                
                UILabel *tiShiLabel = [[UILabel alloc] initWithFrame:CGRectMake(label.right, 0, _backView.width - label.right - 28, subView.height)];
                tiShiLabel.textColor = COLORFROMCODE(0xF95B45, 1);
                tiShiLabel.font = kFont(13);
                tiShiLabel.textAlignment = NSTextAlignmentRight;
                [subView addSubview:tiShiLabel];
                
                UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(tiShiLabel.right, 14.5, 16, 16)];
                imageV.image = [UIImage imageNamed:@"more-2@3x"];
                [subView addSubview:imageV];
            } else {
                _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 45, _backView.width, 45)];
                _label.textColor = COLORFROMCODE(0x9B9B9B, 1);
                _label.textAlignment = NSTextAlignmentCenter;
                _label.font = kFont(13);
                [_backView addSubview:_label];
                
                _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 55, _backView.width - 30, kMaric)];
                _titleLabel.textColor = COLORFROMCODE(0x393939, 1);
                _titleLabel.font = kFont(16);
                [_backView addSubview:_titleLabel];
                
                _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, _titleLabel.bottom, _backView.width - 30, 35)];
                _contentLabel.numberOfLines = 0;
                _contentLabel.textColor = COLORFROMCODE(0x4A4A4A, 1);
                _contentLabel.font = kFont(13);
                [_backView addSubview:_contentLabel];

                _titleLabel.hidden = YES;
                _contentLabel.hidden = YES;
            }
        }
    }
    return self;
}
- (void)setDic:(NSDictionary *)dic{
    _titleLabel.text = [NSString stringWithFormat:@"%@ %@",dic[@"ADD_NAME"],dic[@"MOBILE"]];
    _contentLabel.text = [NSString stringWithFormat:@"%@ %@ %@ %@",dic[@"PROVINCE_NAME"],dic[@"CITY_NAME"],dic[@"REGION_NAME"],dic[@"DE_ADDRESS"]];
    _backView.frame = CGRectMake(15, kRow, kScreenWideth - 30, 110);
}
- (void)setType:(NSString *)type{
    // 1登陆成功,其他代表没登陆
    if ([type isEqualToString:@"1"]) {
        _label.hidden = YES;
        _titleLabel.hidden = NO;
        _contentLabel.hidden = NO;
    } else if([type isEqualToString:@"0"]){
        _label.hidden = NO;
        _titleLabel.hidden = YES;
        _contentLabel.hidden = YES;
        _label.text = @"登录后查看常用地址";
        _backView.frame = CGRectMake(15, kRow, kScreenWideth - 30, 90);
    } else {
        _label.text = @"您还没有添加服务地址";
        _backView.frame = CGRectMake(15, kRow, kScreenWideth - 30, 90);
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
